package  com.sat.common.network

import okhttp3.Interceptor

class RetrofitParams {
    var url: String? = null
    var logListener: LogListener? = null
    var globalParamsListener: GlobalParamsListener? = null
    var dataResponseListener: DataResponseListener? = null
    var customInterceptor: Interceptor? = null

    private constructor() {}

    private constructor(mBuilder: Builder) {
        url = mBuilder.url
        logListener = mBuilder.mLogListener
        globalParamsListener = mBuilder.mGlobalParamsListener
        dataResponseListener = mBuilder.mDataRspListener
        customInterceptor = mBuilder.customInterceptor
    }

    class Builder {
        var url: String? = null
        var mLogListener: LogListener? = null
        var mGlobalParamsListener: GlobalParamsListener? = null
        var mDataRspListener: DataResponseListener? = null
        var customInterceptor: Interceptor? = null
        fun baseUrl(url: String?): Builder {
            this.url = url
            return this
        }

        fun addLogListener(mLogListener: LogListener?): Builder {
            this.mLogListener = mLogListener
            return this
        }

        fun addCustomInterceptor(interceptor: Interceptor?): Builder {
            this.customInterceptor = interceptor
            return this
        }

        fun addGlobalParamsListener(mGlobalParamsListener: GlobalParamsListener?): Builder {
            this.mGlobalParamsListener = mGlobalParamsListener
            return this
        }

        fun addDataResponseListener(mRspListener: DataResponseListener?): Builder {
            mDataRspListener = mRspListener
            return this
        }

        fun build(): RetrofitParams {
            return RetrofitParams(this)
        }
    }

    companion object {
        fun newBuilder(): Builder {
            return Builder()
        }
    }
}